package com.wzdigit.wms.hm.common.enums;

import java.util.*;

/**
 * 库位参数枚举类
 * @author yangdongjie
 * @LocationEnum.java
 * @2020年12月30日下午4:04:17
 */
public enum LocationEnum implements BaseEnum {
	
	/** 
	 * LocUsage
	 * 使用方式/用途：
	 * 箱拣货库位、件拣货库位、箱/件拣货库位、存储库位、过渡库位、理货站、组装工作区
	 */
	LOC_USAGE_A(1, "箱拣货库位", "LocUsage"), 
	LOC_USAGE_B(2, "件拣货库位", "LocUsage"), 
	LOC_USAGE_C(3, "箱/件拣货库位", "LocUsage"),
	LOC_USAGE_D(4, "存储库位", "LocUsage"), 
	LOC_USAGE_E(5, "过渡库位", "LocUsage"), 
	
	/**
	 * LocType
	 * 库位类型：
	 * 地面平仓、重力式货架、货架、窄巷道货架
	 */
	LOC_TYPE_A(11, "地面平仓", "LocType"), 
	LOC_TYPE_B(12, "重力式货架", "LocType"), 
	LOC_TYPE_C(13, "货架", "LocType"),
	
	/**
	 * LocAttr
	 * 属性
	 * 正常、封存、管控、禁入
	 */
	LOC_ATTR_A(21, "正常", "LocAttr"), 
	LOC_ATTR_B(22, "封存", "LocAttr"), 
	LOC_ATTR_C(23, "管控", "LocAttr"),
	LOC_ATTR_D(24, "禁入", "LocAttr"),
	
	/**
	 * LocHandling
	 * 库位处理
	 * 箱、托盘、其他
	 */
	LOC_HANDLING_A(31, "箱", "LocHandling"), 
	LOC_HANDLING_B(32, "托盘", "LocHandling"), 
	LOC_HANDLING_C(33, "其他", "LocHandling"),
	
	/**
	 * Demand
	 * 周转需求：
	 * 快速周转、中速周转、慢速周转
	 */
	DEMAND_A(11, "快速周转", "Demand"), 
	DEMAND_B(12, "中速周转", "Demand"), 
	DEMAND_C(13, "慢速周转", "Demand");
	
	/**
	 * 枚举值
	 */
	public int code;

	/**
	 * 枚举名称
	 */
	public String enumName;

	/**
	 * 枚举实体类属性描述
	 */
	public String description;

	LocationEnum(String enumName, String description) {
		this.enumName = enumName;
		this.description = description;
	}

	LocationEnum(int code, String enumName, String description) {
		this.code = code;
		this.enumName = enumName;
		this.description = description;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public static LocationEnum getEnumByCode(int enumCode) {
		LocationEnum[] values = LocationEnum.values();
		LocationEnum samplingEnum = null;

		for (LocationEnum value : values) {
			if (value.getCode() == enumCode) {
				samplingEnum = value;
			}
		}
		return samplingEnum;
	}

	public static LocationEnum getEnumByName(String enumName) {
		LocationEnum[] values = LocationEnum.values();
		LocationEnum repairEnum = null;

		for (LocationEnum value : values) {
			if (value.getEnumName() == enumName) {
				repairEnum = value;
			}
		}
		return repairEnum;
	}

	public String getEnumName() {
		return enumName;
	}

	public void setEnumName(String enumName) {
		this.enumName = enumName;
	}
	
	public static Integer getCodeByEnumNameAndDescription(String enumName, String enumDescription) {
		LocationEnum[] values = LocationEnum.values();
		for (LocationEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)
					&& Objects.equals(value.getEnumName(), enumName)) {
				return value.getCode();
			}
		}
		return null;
	}

	public static Map<Integer, String> getEnumByDescription(String enumDescription) {
		Map<Integer, String> enumMap = new HashMap<Integer, String>();
		LocationEnum[] values = LocationEnum.values();
		for (LocationEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)) {
				enumMap.put(value.getCode(), value.getEnumName());
			}
		}
		return enumMap;
	}
	
	public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		LocationEnum[] values = LocationEnum.values();
		for (LocationEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)) {
				Map<String, Object> enumMap = new HashMap<String, Object>(2);
				enumMap.put("code", value.getCode());
				enumMap.put("name", value.getEnumName());
				list.add(enumMap);
			}
		}
		return list;
	}
}
